package com.wu.xtkong.myInterceptor;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.context.annotation.Configuration;

/**
 * @author 吴冬冬
 * @version 创建时间：2017年4月28日 下午2:51:59
 * 
 */
//@Aspect
//@Configuration
public class MyCacheInterceptor {
	@Pointcut("execution(* com.wu.web.service.impl..*(..))")
	private void anyMethod() {
	}// 定义一个切入点

	@Before("anyMethod() && args(name)")
	public void doAccessCheck(String name) {
		System.out.println(name);
		System.out.println("前置通知");
	}

	@AfterReturning("anyMethod()")
	public void doAfter() {
		System.out.println("后置通知");
	}

	@After("anyMethod()")
	public void after() {
		System.out.println("最终通知");
	}

	@AfterThrowing("anyMethod()")
	public void doAfterThrow() {
		System.out.println("例外通知");
	}

	@Around("anyMethod()")
	public Object doBasicProfiling(ProceedingJoinPoint pjp) throws Throwable {
//		Class<? extends ProceedingJoinPoint> clazz = pjp.getClass();
//		Annotation[] annotations = clazz.getAnnotations();
		
		System.out.println("进入环绕通知");
		Object object = pjp.proceed();// 执行该方法
		System.out.println("退出方法");
		return object;
	}
}
